// 引入axios实例发送请求
import  request  from "@/utils/request"
// 类型约束
import type {CategoryListModel} from './model/categoryData'

// 集中管理路径
// 2. 使用枚举来存储目标接口
enum Api {
  getCategory1ListApi = '/admin/product/getCategory1',
  getCategory2ListApi = '/admin/product/getCategory2',
  getCategory3ListApi = '/admin/product/getCategory3'
}

/**
 * 获取一级导航栏参数 发送请求函数
 */
export const reqCategory1ListData = ()=>{
  return request.get<any,CategoryListModel>(Api.getCategory1ListApi)
}

/**
 * 根据一级ID获取二级分类的数据
 * @returns 
 */
 export const reqGetCategory2ListData = (category1Id:number) => {
  return request.get<any,CategoryListModel>(Api.getCategory2ListApi+`/${category1Id}`)
}

/**
 * 5. 获取三级分类数据
 * @param category2Id 
 * @returns 
 */
 export const reqGetCategory3ListData = (category2Id:number) => {
  return request.get<any,CategoryListModel>(`${Api.getCategory3ListApi}/${category2Id}`)
}